﻿using System;

namespace er
{
    //********ref在往方法中传入参数前需要赋值
    class Work1_ref
    {
        static void Main(string[] args)
        {
            int[] arr = new int[4];
            for (int i = 0; i < 4; i++)
            {
                Console.WriteLine("请输入第{0}个值：", (i + 1));
                int a = int.Parse(Console.ReadLine());
                arr[i] = a;
            }
            int max = arr[0];
            int min = arr[0];
            double avg = arr[0];
            Work1_ref evaluation = new Work1_ref();
            Console.WriteLine("**************");
            Console.WriteLine("和为：" + evaluation.Count(arr, ref max, ref min, ref avg)); ;
            Console.WriteLine("最大值为：" + max);
            Console.WriteLine("最小值为：" + min);
            Console.WriteLine("平均值为：" + avg);
        }

        public double Count(int[] arr, ref int max, ref int min, ref double avg)
        {
            double sum = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max) { max = arr[i]; };
                if (arr[i] < min) { min = arr[i]; };
                sum += arr[i];
                avg = sum / arr.Length;
            }
; return sum;
        }
    }
}
